C code for PEGetSelectedPrinter

The following code demonstrates how to use the PEGetSelectedPrinter function:

BOOL            result;
HANDLE    driverHandle;
short        driverLength;
char        *driverString;
HANDLE    printerHandle;
short        printerLength;
char        *printerString;
HANDLE    portHandle;
short        portLength;
char        *portString;
struct     DEVMODE *pd;
result = PEGetSelectedPrinter(Job, &driverHandle,
&driverLength, &printerHandle, &printerLength,
&portHandle, &portLength, &pd);
if (!result){
    // Handle error
}
    // Allocate buffers
driverString = (char*)malloc(driverLength);
printerString = (char*)malloc(printerLength);
portString = (char*)malloc(portLength);
    // Retrieve strings if (!PEGetHandleString(driverHandle, driverString, driverLength)){
    // Handle error
}
if (!PEGetHandleString(printerHandle, printerString, interLength)){
    // Handle error
}
if (!PEGetHandleString(portHandle, portString, portLength)){
    // Handle error
}


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com